home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
cuj1008.zip
/
1008016A
< prev
next >
Wrap
Text File
|
1992-06-12
|
642b
|
34 lines
Listing 5 -- system.c
/* system function -- UNIX version */
#include <stdlib.h>
/* UNIX system calls */
int _Execl(const char *, const char *, ...);
int _Fork(void);
int _Wait (int *);
int (system)(const char *s)
{ /* send text to system command line processor */
if (s)
{ /* not just a test */
int pid = _Fork();
if (pid < 0)
; /* fork failed */
else if (pid == 0)
{ /* continue here as child */
_Execl("/bin/sh", "sh", "-c", s, NULL);
exit(EXIT_FAILURE);
}
else /* continue here as parent */
while (_Wait(NULL) != pid)
; /* wait for child */
}
return (-1);
}